package com.elm_springboot_s.controller;

import com.elm_springboot_s.pojo.Food;
import com.elm_springboot_s.pojo.RespondMessage;
import com.elm_springboot_s.service.FoodService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/food")
@Api(tags = "食品相关接口")
public class FoodController {

    @Autowired
    private FoodService foodService;

    @GetMapping("/listFoodByBusinessId")
    @ApiOperation("根据商家编号查询所属食品信息")
    public RespondMessage<List<Food>> listFoodByBusinessId(Integer businessId) {
        try {
            List<Food> foods = foodService.listFoodByBusinessId(businessId);
            return RespondMessage.success(foods);
        } catch (Exception e) {
            return RespondMessage.error("查询食品信息失败：" + e.getMessage());
        }
    }
} 